package com.springboot.template.thread.cycle;

public class Test {
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                System.out.println("Thread = " + Thread.currentThread().getName());
                try {
                    Thread.sleep(1 * 1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("Thread = " + Thread.currentThread().getName() + "即将销毁");
        });
//        thread.start();
        /**
        main:ID 20
        main:名称 Thread-0
        Thread = Thread-0
        main:状态 RUNNABLE
        main:优先级 5
        main:后台线程 false
        main:活着 true
        main:被中断 false
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0
        Thread = Thread-0即将销毁
        */
        System.out.println(Thread.currentThread().getName() + ":ID " + thread.getId());
        System.out.println(Thread.currentThread().getName() + ":名称 " + thread.getName());
        System.out.println(Thread.currentThread().getName() + ":状态 " + thread.getState());
        System.out.println(Thread.currentThread().getName() + ":优先级 " + thread.getPriority());
        System.out.println(Thread.currentThread().getName() + ":后台线程 " + thread.isDaemon());
        System.out.println(Thread.currentThread().getName() + ":活着 " + thread.isAlive());
        System.out.println(Thread.currentThread().getName() + ":被中断 " + thread.isInterrupted());
        thread.start();
        /**
         main:ID 20
         main:名称 Thread-0
         main:状态 NEW
         main:优先级 5
         main:后台线程 false
         main:活着 false
         main:被中断 false
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0
         Thread = Thread-0即将销毁
         */
    }
}
